Products = {
	_images_input_count: 0,	
	
	add_image_upload_input: function() {
		var example = jQuery('#file_input_example');
		example.find('input[type=file]')
			.attr('name', 'image_' + Products._images_input_count++);
		jQuery('#file_input_container').append(example.html());
		Forms2.resetFileInputs();
	},
	
	M_View: {
		PREVIEW_ELEMENT_WIDTH: 240,
		
		_preview_current_position: 0,
		_preview_left_boundry: 0,
		_preview_right_boundry: 0,
		
		init: function() {
			this._init_preview();
		},
		
		_init_preview: function() {
			var that = this;
			var container = jQuery('.p-view .preview ul');
			var items = container.find('li');
			
			container.width(items.length * this.PREVIEW_ELEMENT_WIDTH + 'px');
			
			this._preview_left_boundry = (items.length - 1) 
				* this.PREVIEW_ELEMENT_WIDTH * -1;
			this._preview_right_boundry = this.PREVIEW_ELEMENT_WIDTH;
			
			jQuery('.p-view .r-arrow > a').click(function(ev) {
				var npos = that._preview_current_position 
					- that.PREVIEW_ELEMENT_WIDTH;
				
				if (npos < that._preview_left_boundry) {
					return;
				}
				
				that._preview_current_position = npos;
				
				jQuery('.preview > ul').animate({
					left: npos + 'px'
				});
			});
			
			jQuery('.p-view .l-arrow > a').click(function(ev){
				var npos = that._preview_current_position 
				+ that.PREVIEW_ELEMENT_WIDTH;
			
				if (npos >= that._preview_right_boundry) {
					return;
				}
				
				that._preview_current_position = npos;
				
				jQuery('.preview > ul').animate({
					left: npos + 'px'
				});
			});
		}
	}
};